Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Pages] Update Nuxt framework guide and improve bindings coverage #12953

Merged
merged 17 commits into from
Feb 23, 2024

Conversation

jculvey
Copy link
Contributor

@jculvey jculvey commented Feb 13, 2024

This change adds more detail to the bindings section of the Nuxt framework guide on how to configure bindings in dev and production. There's a lot of overlap between this PR and this update to the Qwik guide.

Copy link

cloudflare-workers-and-pages bot commented Feb 13, 2024

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 131606c
Status: ✅  Deploy successful!
Preview URL: https://a4f4a0d6.cloudflare-docs-7ou.pages.dev
Branch Preview URL: https://jculvey-nuxt-bindings-update.cloudflare-docs-7ou.pages.dev

View logs

Copy link

github-actions bot commented Feb 13, 2024

Files with changes (up to 15)

Original Link Updated Link
https://developers.cloudflare.com/pages/framework-guides/deploy-a-nuxt-site/ https://jculvey-nuxt-bindings-update.cloudflare-docs-7ou.pages.dev/pages/framework-guides/deploy-a-nuxt-site/
https://developers.cloudflare.com/pages/framework-guides/nextjs/deploy-a-nextjs-site/ https://jculvey-nuxt-bindings-update.cloudflare-docs-7ou.pages.dev/pages/framework-guides/nextjs/deploy-a-nextjs-site/
https://developers.cloudflare.com/pages/framework-guides/deploy-a-blazor-site/ https://jculvey-nuxt-bindings-update.cloudflare-docs-7ou.pages.dev/pages/framework-guides/deploy-a-blazor-site/
https://developers.cloudflare.com/pages/framework-guides/deploy-a-brunch-site/ https://jculvey-nuxt-bindings-update.cloudflare-docs-7ou.pages.dev/pages/framework-guides/deploy-a-brunch-site/
https://developers.cloudflare.com/pages/framework-guides/deploy-a-docusaurus-site/ https://jculvey-nuxt-bindings-update.cloudflare-docs-7ou.pages.dev/pages/framework-guides/deploy-a-docusaurus-site/
https://developers.cloudflare.com/pages/framework-guides/deploy-a-gatsby-site/ https://jculvey-nuxt-bindings-update.cloudflare-docs-7ou.pages.dev/pages/framework-guides/deploy-a-gatsby-site/
https://developers.cloudflare.com/pages/framework-guides/deploy-a-gridsome-site/ https://jculvey-nuxt-bindings-update.cloudflare-docs-7ou.pages.dev/pages/framework-guides/deploy-a-gridsome-site/
https://developers.cloudflare.com/pages/framework-guides/deploy-a-hexo-site/ https://jculvey-nuxt-bindings-update.cloudflare-docs-7ou.pages.dev/pages/framework-guides/deploy-a-hexo-site/
https://developers.cloudflare.com/pages/framework-guides/deploy-a-hono-site/ https://jculvey-nuxt-bindings-update.cloudflare-docs-7ou.pages.dev/pages/framework-guides/deploy-a-hono-site/
https://developers.cloudflare.com/pages/framework-guides/deploy-a-hugo-site/ https://jculvey-nuxt-bindings-update.cloudflare-docs-7ou.pages.dev/pages/framework-guides/deploy-a-hugo-site/
https://developers.cloudflare.com/pages/framework-guides/deploy-a-jekyll-site/ https://jculvey-nuxt-bindings-update.cloudflare-docs-7ou.pages.dev/pages/framework-guides/deploy-a-jekyll-site/
https://developers.cloudflare.com/pages/framework-guides/deploy-a-pelican-site/ https://jculvey-nuxt-bindings-update.cloudflare-docs-7ou.pages.dev/pages/framework-guides/deploy-a-pelican-site/
https://developers.cloudflare.com/pages/framework-guides/deploy-a-preact-site/ https://jculvey-nuxt-bindings-update.cloudflare-docs-7ou.pages.dev/pages/framework-guides/deploy-a-preact-site/
https://developers.cloudflare.com/pages/framework-guides/deploy-a-qwik-site/ https://jculvey-nuxt-bindings-update.cloudflare-docs-7ou.pages.dev/pages/framework-guides/deploy-a-qwik-site/
https://developers.cloudflare.com/pages/framework-guides/deploy-a-react-site/ https://jculvey-nuxt-bindings-update.cloudflare-docs-7ou.pages.dev/pages/framework-guides/deploy-a-react-site/

@jculvey jculvey changed the title Update Nuxt framework guide and improve bindings coverage [Pages] Update Nuxt framework guide and improve bindings coverage Feb 13, 2024

You will be asked to authorize access to your GitHub account if you have not already done so. Cloudflare needs this so that it can monitor and deploy your projects from the source. You may narrow access to specific repositories if you prefer; however, you will have to manually update this list [within your GitHub settings](https://github.com/settings/installations) when you want to add more repositories to Cloudflare Pages.

Select the new GitHub repository that you created and, in the **Set up builds and deployments** section, provide the following information:

{{<pages-build-preset framework="nuxt-js">}}
{{<pages-build-preset framework="nuxt">}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this change is correct:
Screenshot 2024-02-13 at 18 41 10

If you want to rename the preset you'll also have to rename it here I think:

But I'd be careful about the above since I think this file is also used to generate the dashboard presets... so before updating it I double check that it is ok to do so

content/pages/framework-guides/deploy-a-nuxt-site.md Outdated Show resolved Hide resolved

A [binding](/pages/functions/bindings/) allows your application to interact with Cloudflare developer products, such as [KV](/kv/reference/how-kv-works/), [Durable Object](/durable-objects/), [R2](/r2/), and [D1](https://blog.cloudflare.com/introducing-d1/).
### Accessing bound resources in your Nuxt application
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

calling "bindings" "bound resources" make things more confusing in my opinion 😅

Co-authored-by: Dario Piotrowicz <dario@cloudflare.com>
@github-actions github-actions bot added size/m and removed size/s labels Feb 16, 2024
@XoL1507

This comment was marked as spam.


In Nuxt, add server-side code via [Server Routes and Middleware](https://nuxt.com/docs/guide/directory-structure/server#server-directory). The `defineEventHandler()` method is used to define your API endpoints in which you can access Cloudflare's context via the provided `context` field. The `context` field allows you to access any bindings set for your application.

The following code block shows an example of accessing a KV namespace in Nuxt.

```typescript
---
filename: src/my-endpoint.get.ts
highlight: [2, 3]
filename: server/api/hello.ts / server/api/hello.js
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@deadlypants1973 this is very ugly! 😓

Screenshot 2024-02-22 at 01 27 12

I'm always unsure what's best in these situations... shall we add a js/ts switcher even if completely unnecessary? (since the file content is always the same)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for switcher!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switcher added 🙂👍

Although it showcases a small coloring quirk 😓
switcher

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(PS: the coloring difference seems a bit wrong to me... I wonder if it is intentional...)


{{<Aside type="note">}}

Projects created with C3 have a default `env.d.ts` file.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@deadlypants1973 sorry my bad... C3 does not currently do that (and I think it should)

I can remove this bit now or we can add it to C3 before we merge this PR, please let me know what you prefer 🙂

content/pages/framework-guides/deploy-a-nuxt-site.md Outdated Show resolved Hide resolved
$ git commit -m "Initial commit"

$ git branch -M main
$ git remote add origin https://github.com/<YOUR_GH_USERNAME>/<REPOSITORY_NAME>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$ git remote add origin https://github.com/<YOUR_GH_USERNAME>/<REPOSITORY_NAME>
$ git remote add origin https://github.com/<YOUR_GH_USERNAME>/<REPOSITORY_NAME>.git

content/pages/framework-guides/deploy-a-nuxt-site.md Outdated Show resolved Hide resolved
content/pages/framework-guides/deploy-a-nuxt-site.md Outdated Show resolved Hide resolved
deadlypants1973 and others added 2 commits February 23, 2024 14:53
PCX

Co-authored-by: Pedro Sousa <680496+pedrosousa@users.noreply.github.com>
@deadlypants1973 deadlypants1973 merged commit a437cc8 into production Feb 23, 2024
7 checks passed
@deadlypants1973 deadlypants1973 deleted the jculvey/nuxt-bindings-update branch February 23, 2024 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants